<?php

namespace App\services;

use AlphaSnow\Flysystem\Aliyun\AliyunFactory;

class OSS {

    /**
     * 使用外网上传文件
     */
  public static function publicUpload($saveName, $filePath)
  {

      (new AliyunFactory())->createFilesystem([
          "access_key_id" =>  config('admin.OSS_ACCESS_KEY_ID'),             // Required, YourAccessKeyId
          "access_key_secret" => config('admin.OSS_ACCESS_KEY_SECRET'),   // Required, YourAccessKeySecret
          "endpoint" =>  config('admin.OSS_ENDPOINT'),    // Required, Endpoint
          "bucket" =>  config('admin.OSS_BUCKET'),                       // Required, Bucket
      ])->writeStream($saveName, fopen($filePath, 'r'));
  }


}
